Refactor macro tests so that we can move macros #524
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR was originally going to be reorganizing the macros to be more aligned with dbt-core. When I tried to move a macro, I realized how insane our macro tests were, as they all broke.
In this PR:
Now, in a world of fine-grained unit tests, this would not be as gnarly, because part of the issue here is needing to load in the dependencies of the macro. For example, if your macro references file_format_clause(), you'll need the template context to know how to resolve that. In this case, it comes from dbt-spark, in the adapters.sql file. An alternative approach is to mock out everything, but it may be quite hard to judge if the generated sql is actually something that will work. So instead, I give pytest fixtures that can be overridden in order to give whatever template resolution you need to get the macros to work. In my next commit, I'll add documentation to base.
Checklist
CHANGELOG.md
and added information about my change to the "dbt-databricks next" section.